package store.lunangangster.engine.impl.entity;

import java.util.Date;
import java.util.List;
import store.lunangangster.bpmn.model.FlowElement;
import store.lunangangster.engine.impl.entity.mgr.VariableScope;
import store.lunangangster.engine.impl.runtime.ProcessInstance;
import store.lunangangster.engine.repository.Execution;

public interface ExecutionEntity extends Execution, ProcessInstance, Entity, VariableScope {

  void setId(String id);

  void setName(String name);

  void setProcessInstanceId(String id);

  void setProcessDefinitionId(String processDefinitionId);

  void setParentId(String id);

  void setRootId(String id);

  void setProcessDefinitionKey(String processDefinitionKey);

  void setDeploymentId(String deploymentId);

  void setStartTime(Date startTime);

  void setModelId(String modelId);

  void setIsActive(boolean isActive);

  ExecutionEntity getParent();

  /**
   * 该方法调用时，如果该对象中的childExecutions为空，则会查询数据库并封装childExecutions
   * @return childExecutions, not null
   */
  List<ExecutionEntity> getChildExecutions();

  void addChildExecutions(ExecutionEntity execution);

  ProcessInstance getRootProcessInstance();

  /**
   * 该方法调用时，会通过缓存的currentFlowElement以及持久化的modelId来获取
   * 当前Execution所停留在的FlowElement
   *
   * @return  当前Execution所停留在的FlowElement
   */
  FlowElement getCurrentFlowElement();

  void setParent(ExecutionEntity parentExecution);

  void setRootProcessInstance(ProcessInstance rootProcessInstance);

  void setCurrentFlowElement(FlowElement flowElement);

  boolean isActive();

  void setActive(boolean isActive);

  boolean isScope();

  void setScope(boolean isScope);
}
